//
//  IMAFNetworkUsage.m
//  IosFrameWork
//
//  Created by imaginedays on 13-4-1.
//  Copyright (c) 2013年 imagindays. All rights reserved.
//

#import "IMAFNetworkUsage.h"
#import "AFJSONRequestOperation.h"

static NSString * const APPBaseURLString = @"https://alpha-api.app.net/";

@implementation IMAFNetworkUsage

+ (IMAFNetworkUsage *)sharedClient
{
    static IMAFNetworkUsage *sharedClient = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        sharedClient = [[IMAFNetworkUsage alloc]initWithBaseURL:[NSURL URLWithString:APPBaseURLString]];
    });
    
    return sharedClient;
}

- (id)initWithBaseURL:(NSURL *)url
{
    self = [super initWithBaseURL:url];
    if (!self) {
        return nil;
    }
    [self registerHTTPOperationClass:[AFJSONRequestOperation class]];
    [self setDefaultHeader:@"Accept" value:@"application/json"];
    return self;
}

@end
